/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-11
 * Time: 22:08
 */
public class Test {
    public boolean checkWon(int[][] board) {
        // write code here
        int i = 0, j = 0, sum = 0;
        for (i = 0; i < board.length; i++) {
            sum = 0;
            for (j = 0; j < board[0].length; j++) {
                sum += board[i][j];
            }
            if (sum == board[0].length || sum == -(board[0].length)) return true;
        }

        for (j = 0; j < board[0].length; j++) {
            sum = 0;
            for (i = 0; i < board.length; i++) {
                sum += board[i][j];
            }
            if (sum == board.length || sum == -board.length) return true;
        }

        sum = 0;
        i = 0;
        j = 0;
        while (i < board.length && j < board[0].length) {
            sum += board[i++][j++];
        }
        if (sum == board.length) return true;

        sum = 0;
        i = 0;
        j = board[0].length - 1;
        while (i < board.length && j >= 0) {
            sum += board[i++][j--];
        }
        if (sum == board.length) return true;

        return false;

    }
}
